package com.easytopit.demo.spring.mvc.controller;

import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RestControllerDemo {
	
	@RequestMapping("/res/body")
	public @ResponseBody/*直接将返回当成内容发送*/ String res(@RequestBody(required=false)/*获取数据体*/ String body, HttpServletResponse response){
		return "OK -> " + body;
	}
	
//	@RequestMapping("/res/body")
//	public void res(@RequestBody/*获取数据体*/ String body, HttpServletResponse response){
//		response.getWriter().write("OK -> " + body);   @ResponseBody/*直接将返回当成内容发送*/ String
//	}
	
	@PostMapping("/res/ingore")
	public String resIngore(@RequestBody String body){
		return "OK -> " + body;
	}
	
	@GetMapping("/res/ingore.htm")
	public String resIngor(@RequestBody(required=false) String body){
		return "9999";
	}
	
}
